﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/static/css/common/reset.css" />
    <link rel="stylesheet" href="/static/css/associate.css" />
    <link rel="stylesheet" href="/static/css/sweetalert.min.css" />
    <link rel="stylesheet" href="/static/js/simditor/styles/simditor.css" />
    <link rel="stylesheet" href="/static/js/simditor/styles/simditor-html.css" />
    <link rel="stylesheet" href="/static/css/jquery-validate.css" />
    <title>修改社团信息</title>
</head>
<body>
    <div class="associate">
        <div id="divHeader"></div>
        <section class="assoc-content container clearfix">
            <div class="assoc-c-left fl">

                <div id="divNavigation"></div>
            </div>

            <form id="secondStepForm" class="assoc-c-right fr" ng-app="myApp" ng-controller="ctrlreviseinfo">
                <div class="assoc-cr-resiveInfo file" ng-model="names" style="margin-top: 0px">
                    <div class="reg-tcom-item mt10 clearfix">
                        <label>社团名称：</label>
                        <div class="form_control">
                            <input type="text" class="required" data-tip="请输入社团名称" data-valid="isNonEmpty" data-error="社团名称不能为空" placeholder="请输入社团名称" value={{names.Name}} name="name" />
                        </div>
                    </div>
                    <div class="reg-tcom-item mt10 clearfix">
                        <label>社团口号：</label>
                        <div class="form_control">
                            <input type="text" class="required" data-tip="请输入社团口号" data-valid="isNonEmpty" data-error="社团口号不能为空" placeholder="请输入社团口号" value="{{names.Remark}}  " name="Remark" />
                        </div>
                    </div>
                    <div class="reg-tcom-item mt10 charge clearfix">
                        <label>社团负责人：</label>
                        <div class="form_control">
                            <input type="text" class="required" data-tip="请输入社团负责人" data-valid="isNonEmpty" data-error="社团负责人不能为空" placeholder="请输入社团负责人" value="{{names.ChargeName}}" name="belongName" />
                        </div>
                    </div>
                    <div class="reg-tcom-item mt10 clearfix">
                        <label>社团级别：</label>
                        <div class="form_control">
                            <select style="width: 207px;" class="required" data-valid="isNonEmpty" data-tip="请选择社团级别" data-error="请选择社团级别" name="nature">
                                <option value="">请选择院校级</option>
                                <option value="900000001">校级</option>
                                <option value="900000002">院级</option>
                            </select>
                        </div>
                    </div>

                    <div class="reg-tcom-item mt10 communityType clearfix">
                        <label>社团类型：</label>
                        <div class="form_control">
                            <select name="type" class="required" data-valid="isNonEmpty" data-tip="请选择社团类型" data-error="请选择社团类型" id="type" onchange="changeType(this.value)">
                                <option value="">请选择社团分类</option>
                                <option value="900000112">组织类</option>
                                <option value="900000113">社团类</option>
                            </select>
                        </div>
                        <div class="form_control">
                            <select name="typedetail" class="required" data-valid="isNonEmpty" data-tip="请选择社团名称" data-error="请选择社团名称" required id="typedetail">
                                <option value="">请选择社团名称</option>
                            </select>
                        </div>
                    </div>
                    <div class="reg-tcom-item mt10 clearfix">
                        <label>社团规模：</label>
                        <div class="form_control">
                            <select style="width: 207px;" class="required" data-valid="isNonEmpty" data-tip="请选择社团规模" data-error="请选择社团规模" name="amount" id="amount">
                                <option value="">请选择社团规模</option>
                            </select>
                        </div>
                    </div>
                    <div class="reg-tcom-item mt10 clearfix">
                        <label>部门数量：</label>
                        <div class="form_control">
                            <input type="text" class="required" data-valid="isNonEmpty" data-tip="请输入部门数量" data-error="请输入部门数量" placeholder="请选择部门数量" value="{{names.DeptAmount}}" name="deptAmount" />
                        </div>
                    </div>
                    <div class="reg-tcom-item mt10 clearfix">
                        <label>学校地址：</label>
                        <div class="form_control">
                            <input type="text" class="required" data-valid="isNonEmpty" data-tip="请输入学校地址" data-error="请输入学校地址" placeholder="请输入学校地址" value={{names.SchoolAddress}} name="schoolAddress" />
                        </div>
                    </div>
                    <p class="assoc-crb-cardTitle file">重新提交认证证件<span class="colorRed"></span></p>
                    <!-- <ul class="uploadMulBtn uploadList clearfix">
                        <li>
                            <a href="javascript:;" class="up-fileBook" id="up-fileBook">
                                身份证反面
                                <input type="file" name="IDFront" class="reg-tauLeft-btnInput" />
                            </a>
                            <h3 class="up-fileNameBook">
                                <label>已添加附件：</label>
                                <p class="up-file-content">
                                </p>
                            </h3>
                        </li>
                        <li>
                            <a href="javascript:;" class="up-fileBook" id="up-filePhoto">
                                身份证正面
                                <input type="file" name="IDOpposite" class="reg-tauLeft-btnInput" />

                            </a>
                            <h3 class="up-fileNameBook">
                                <label>已添加附件：</label>
                                <p class="up-file-content">
                                </p>
                            </h3>
                        </li>
                        <li>
                            <a href="javascript:;" class="up-fileBook" id="up-filePhoto">
                                学生证内页
                                <input type="file" name="StuIDCardContent" class="reg-tauLeft-btnInput" />

                            </a>
                            <h3 class="up-fileNameBook">
                                <label>已添加附件：</label>
                                <p class="up-file-content">
                                </p>
                            </h3>
                        </li>
                        <li>
                            <a href="javascript:;" class="up-fileBook" id="up-filePhoto">
                                学生证封面
                                <input type="file" name="StuIDCardCover" class="reg-tauLeft-btnInput" />
                            </a>
                            <h3 class="up-fileNameBook">
                                <label>已添加附件：</label>
                                <p class="up-file-content">
                                </p>
                            </h3>
                        </li>

                    </ul> -->
                    <div class="reg-tAccount-uploadBtns clearfix">
                        <div class="reg-taUploadBtns-left fl" id="reg-taUploadBtns-left">
                            <a href="javascript:void(0)" class="reg-tauLeft-btn" name="">
                                学生证封面
                                <div class="form_control file">
                                    <input type="file" data-valid="isNonEmpty" data-tip="请上传学生证封面" data-error="请上传学生证封面" name="StuIDCardContent" class="reg-tauLeft-btnInput required regInchargeFile" />
                                </div>
                                <p class="reg-tauLeft-text">未上传</p>
                            </a>
                            <a href="javascript:void(0)" class="reg-tauLeft-btn" name="">
                                学生证内页
                                <div class="form_control file">
                                    <input type="file" data-valid="isNonEmpty" data-tip="请上传学生证内页" data-error="请上传学生证内页" name="StuIDCardCover" class="reg-tauLeft-btnInput required regInchargeFile" />
                                </div>
                                <p class="reg-tauLeft-text">未上传</p>
                            </a>
                        </div>
                        <div class="reg-taUploadBtns-right fr">
                            <p class="pl5">请根据提供规范上传个人证件照片</p>
                            <ul class="reg-tauRight-ul clearfix mt10" id="reg-tauRight-ul">
                                <!-- <li><img src="/static/images/register3.png" /></li>
                                <li><img src="/static/images/register5.png" /></li> -->
                                <li><img src="/static/images/register6.png" /></li>
                                <li><img src="/static/images/register7.png" /></li>
                            </ul>
                        </div>
                    </div>
                    <input type="button" class="assoc-crb-btn file" value="确认修改" id="submit" />
                </div>
            </form>
        </section>
    </div>
    <div id="divFooter"></div>
    <script type="text/javascript" src="/static/js/ref/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="/static/js/self/common.js"></script>
    <script type="text/javascript" src="/static/js/ref/angular.min.js"></script>
    <script type="text/javascript" src="/static/js/ref/sweetalert.min.js"></script>
    <script src="/static/js/ref/jquery.validate.js"></script>
    <script src="/static/js/ref/linq.min.js"></script>
    <script src="/static/js/self/jquery-validate.js"></script>
    <script>

        common.validator($('form'));

        $("#divHeader").load("/wuc/header.html");
        $("#divFooter").load("/wuc/footer.html");
        $("#divNavigation").load("/wuc/navigation.html");

        var myApp = angular.module('myApp', []);
        common.CreateController({ name: 'ctrlreviseinfo', url: '/api/student/GetAssociation', objType: 'dict', app: myApp });
        common.commonAjax({ type: 'get', url: '/api/student/ListArea', sMethod: GetCity });
        common.commonAjax({ type: 'get', url: '/api/student/ListSchool', sMethod: ListSchool });
        common.commonAjax({ type: 'get', url: '/api/Login/GetStatus', sMethod: AfterAjax });
        common.commonAjax({ type: 'get', url: '/api/student/ListBaseData', sMethod: ListBaseData });
        common.commonAjax({ type: 'get', url: '/api/student/ListAmount', sMethod: ListAmount });
        common.ValidateFormJQ('secondStepForm', 'submit', submitSecondStep)
        function submitSecondStep() {
            common.FormAjax({ type: 'Post', url: '/api/Student/UpdateAssociation', ID: "secondStepForm", sMethod: AfterAjax });
        };
        function AfterAjax(ctx) {
            if (ctx == null) {
                common.alertMessage("无数据.");
                return;
            }

            var str = ctx.ResponseStr.toString();
            switch (str) {
                case "OK":
                    window.location = "./commuityInfo.html";
                    break;
            }
        }

        var lstSchool;
        var lstType;
        var lstAmout;

        function ListSchool(ctx) {
            if (ctx == "" || ctx == null) {
                common.alertMessage("提交错误，请重试！");
                return;
            }
            lstSchool = ctx.ResponseList;
        }
        function ListBaseData(ctx) {
            if (ctx == "" || ctx == null) {
                common.alertMessage("提交错误，请重试！");
                return;
            }
            lstType = ctx.ResponseList;
        }
        function ListAmount(ctx) {
            lstAmout = ctx.ResponseList;
            Enumerable.From(lstAmout).ForEach(function (obj) {
                $("#amount").append("<option value='" + obj.RuleNO + "'>" + obj.Description + "</option>")
            })
        }
        function GetCity(ctx) {
            if (ctx == "" || ctx == null) {
                common.alertMessage("提交错误，请重试！");
                return;
            }
            data = ctx.ResponseList;
            var str = [];
            var result = Enumerable.From(data).ForEach(function (obj) {
                if (obj.Code == 0)
                    return;
                if (str.indexOf(obj.Code) >= 0)
                    return;
                str.push(obj.Code);
                $("#city").append("<option value='" + obj.Code + "'>" + obj.Name + "</option>")
            });
        }
        function changeCity(pno) {
            $("#schoolNO").empty();
            if (pno == "0" || pno == "" || pno == undefined)
                return;
            Enumerable.From(lstSchool).Where("$.CityNO == " + pno + "").ForEach(function (obj) {
                $("#schoolNO").append("<option value='" + obj.SchoolNO + "'>" + obj.SchoolName + "</option>")
            })
        }

        function changeType(pno) {
            $("#typedetail").empty();
            if (pno == "0" || pno == "" || pno == undefined)
                return;
            Enumerable.From(lstType).Where("$.ParentNo == " + pno + "").ForEach(function (obj) {
                $("#typedetail").append("<option value='" + obj.RuleNO + "'>" + obj.Description + "</option>")
            })
        }

        function Listamunt() {
            Enumerable.From(lstAmout).ForEach(function (obj) {
                $("#amount").append("<option value='" + obj.RuleNO + "'>" + obj.Description + "</option>")
            })
        }

        //设置账号信息选择文件
        $("#reg-taUploadBtns-left .regInchargeFile").on(' change', function () {

            /*var filePath = this.files;
            var files_val = '';
            files_val = "已上传：" + filePath[0].name;
            console.log(filePath);
            this.parentElement.parentElement.nextElementSibling.innerHTML = files_val;*/

            var $file = $(this);
            var index_ = $file.parent().parent().index();
            var li_ = $("#reg-tauRight-ul li");
            var fileObj = $file[0];
            var fileVal = fileObj.files[0].name;

            var fileSize = (fileObj.files[0].size / 1024).toFixed(1);
            if (!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(fileVal)) {
                alert("图片类型必须是.gif,jpg,jpeg,png,GIF,JPG,PNG中的一种")
                return false;
            } else if (fileSize > 1024) {
                alert("图片不能大于1M")
                return false;
            }

            var windowURL = window.URL || window.webkitURL;
            var dataURL;
            if (fileObj && fileObj.files && fileObj.files[0]) {
                dataURL = windowURL.createObjectURL(fileObj.files[0]);
                li_.eq(index_).find("img").attr('src', dataURL);
                this.parentElement.nextElementSibling.innerHTML = '已上传：' + fileObj.files[0].name;
            } else {

                dataURL = $file.val();
                var imgObj = document.getElementById("reg-tauRight-ul");
                var li_ = imgObj.getElementByTagName('li');
                // 两个坑:
                // 1、在设置filter属性时，元素必须已经存在在DOM树中，动态创建的Node，也需要在设置属性前加入到DOM中，先设置属性在加入，无效；
                // 2、src属性需要像下面的方式添加，上面的两种方式添加，无效；
                li_[index_].childNodes[0].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                li_[index_].childNodes[0].filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;

            }

        });

    </script>

</body>

</html>
